<?php
/**
 * Introduction: 商品表  goods
 * @author: 杨陈鹏
 * @date: 2016/4/10 16:41
 * @email: yangchenpeng@cdlinglu.com
 */


namespace Common\Model;


use Think\Model;

class GoodsModel extends Model\RelationModel
{

    //定义数据库连接信息
    protected $connection;
    //定义模型字段
    protected $fileds = [
        'id',
        'title',
        'keywords',
        'description',
        'store_id',
        'store_name',
        'category_id',
        'add_time',
        'update_time',
        'views',
        'comment',
        'share_nums',
        'goods_promotion_type',
        'goods_salenum',
        'goods_collect',
        'goods_state',
        'transport_id',
        'goods_freight',
        'goods_star',
        'is_own_shop',
        'product_data',
        'content',
        'publish_time',
        'goods_storage_total',
        'thumb',
        'spec',
        'goods_price',
        'goods_market_price',
        'like',
        'is_distribution',
        'bonus',
    ];
    //定义表名
    protected $tableName = 'goods';

    /**
     * 初始化
     */
    public function _initialize()
    {
        $this->connection = C('Databaese');
    }

    //关联模型
    protected $_link = array(

        'goods_extend' => array(

            'mapping_type' => self::HAS_ONE,
            'mapping_name' => 'goods_extend',
            'class_name' => 'GoodsExtend',
            'foreign_key' => 'goods_id',
            'condition' => 'is_default = 1',


        ),

    );

}
